import { createRouter, createWebHashHistory } from 'vue-router'
import LayoutView from '../LayoutView.vue'

const routes: Array<any> = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/',
    name: 'home',
    component: LayoutView,
    alias: '/index',
    children: [
      {
        path: 'home',
        name: 'home',
        component: () => import('../views/HomeView.vue')
      }
    ]
  },
  {
    path: '/questions',
    name: 'questions',
    component: () => import('../views/QuestionsView.vue')
  },
  {
    path: '/category',
    name: 'category',
    component: () => import('../views/exam/CategoryView.vue')
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/LoginView.vue')
  }
  ,
  {
    path: '/register',
    name: 'register',
    component: () => import('../views/RegisterView.vue')
  }
  ,
  {
    path: '/my',
    name: 'my',
    component: () => import('../views/user/MyView.vue')
  },
  ,
  {
    path: '/detail',
    name: 'detail',
    component: () => import('../views/exam/DetailView.vue')
  }
  ,
  {
    path: '/score',
    name: 'score',
    component: () => import('../views/exam/ScoreView.vue')
  }
  ,
  {
    path: '/testpaper',
    name: 'testpaper',
    component: () => import('../views/exam/TestPaper.vue')
  },
  {
    path: '/findpwd',
    name: 'findpwd',
    component: () => import('../views/user/FindPwd.vue')
  },
  {
    path: '/secure',
    name: 'secure',
    component: () => import('../views/user/SecureView.vue')
  },
  {
    path: '/edit',
    name: 'edit',
    component: () => import('../views/user/EditInfo.vue')
  },
  // 配置404... NotFound （在数组的末位）
  {
    // path:'*', vue2
    path: "/:pathMatch(.*)*",
    name: 'error',
    component: () => import('../views/ErrorView.vue')
  }
]

const router = createRouter({
  // history: createWebHistory(import.meta.env.BASE_URL),
  history: createWebHashHistory(),
  routes,
})

export default router
